#ifndef __EVENT_H__
#define __EVENT_H__
//
#include <windows.h>
//
class Event {    
public:
	Event(bool manualReset = false) {
		_event = ::CreateEvent(0, manualReset ? TRUE : FALSE, FALSE, 0);
	}

	~Event() {
		::CloseHandle(_event);
	}

	void signal() {
		::SetEvent(_event);
	}

	void reset() {
		::ResetEvent(_event);
	}

	bool wait(unsigned int millis) {
		return ::WaitForSingleObjectEx(_event, millis, TRUE) == WAIT_OBJECT_0;
	}

	bool check() {
		return ::WaitForSingleObject(_event, 0) == WAIT_OBJECT_0;
	}

	HANDLE handle() {
		return _event;
	}

private:
	HANDLE _event;
	Event(const Event&);
	Event& operator = (const Event&);
};

#endif
